package org.qqcui.designpattern.patterns.factory.simplefactory.order;

import org.qqcui.designpattern.patterns.factory.simplefactory.pizza.CheesePizza;
import org.qqcui.designpattern.patterns.factory.simplefactory.pizza.GreekPizza;
import org.qqcui.designpattern.patterns.factory.simplefactory.pizza.Pizza;
import org.qqcui.designpattern.patterns.factory.simplefactory.pizza.PepperPizza;

/**
 * 使用简单工厂模式生产pizza
 *
 * @author cuiqingqiang
 * @version 1.0
 * @date 2020-10-17 13:27
 **/
public class PizzaSimpleFactory {

	public static Pizza createPizza(String orderType) {
		Pizza pizza = null;
		if ("greek".equals(orderType)) {
			pizza = new GreekPizza();
			pizza.setName("希腊披萨");
		} else if ("cheese".equals(orderType)) {
			pizza = new CheesePizza();
			pizza.setName("奶酪披萨");
		} else if ("pepper".equals(orderType)) {
			// 新增一种披萨种类，只需要新增一个创建方式就可以了
			pizza = new PepperPizza();
			pizza.setName("胡椒披萨");
		}
		return pizza;
	}
}
